<!doctype html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<div id='sandbox'></div>
<div id="console"></div>
<script>
var sandbox = document.getElementById('sandbox');
var host = document.createElement('div');
var shadowRoot = host.attachShadow({mode: 'open'});
shadowRoot.innerHTML = '<style>* { }</style><div>Shadow</div>';
sandbox.appendChild(host);

debug("Testing &lt;style>...");
var sheet = shadowRoot.styleSheets[0];
var style = shadowRoot.querySelector('style');

shouldBe('sheet.ownerNode', 'style')
shouldBe('style.sheet === sheet', 'true')

debug("Removing &lt;style>...");
shadowRoot.removeChild(style);

shouldBe('style.sheet', 'null')
shouldBe('sheet.ownerNode', 'null')
shouldBe('sheet.cssRules[0].cssText[0]', '"*"')

debug("Re-adding &lt;style>...");
shadowRoot.appendChild(style);
shouldBe('sheet.ownerNode', 'null')
shouldBe('style.sheet === sheet', 'false')
shouldBe('style.sheet.ownerNode', 'style')
</script>
</body>
</html>
